package tpo.controller;

import api.finance.Finance_Api;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import dto.Dto;
import org.springframework.web.bind.annotation.RestController;
import pojo.BuyOrder;
import pojo.Journal;
import pojo.Pay_order;
import pojo.Receipt_order;
import pojo.finance.Day;
import pojo.finance.Fukuandan;
import pojo.finance.Kehuduizhang;
import pojo.finance.Zijinduizhang;
import tpo.service.Receipt_order_Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
public class Receipt_order_Controller implements Finance_Api {

    @Resource
    private Receipt_order_Service receipt_order_service;

    @Override
    public Dto<PageInfo<Receipt_order>> allreceipt_order(Map<String, Object> map) {
        Integer pageNum=Integer.parseInt(map.get("pageNun").toString());
        Integer pageSize=Integer.parseInt(map.get("pageSize").toString());
        //页面的页码标签数
        int navigatePages=5;
        PageHelper.startPage(pageNum,pageSize);//开始分页,设参数
        List<Receipt_order> list =receipt_order_service.allreceipt_order(map);//查询数据
        PageInfo<Receipt_order> pageInfo = new PageInfo<>(list,navigatePages);//数据放入自动参数分页
        Dto dto=new Dto();
        dto.setObj(pageInfo);
        dto.setSuccess(true);
        return dto;
    }

    @Override
    public Dto<Receipt_order> selectReceipt_order(String code) {
        Dto<Receipt_order> dto=new Dto<>();
        dto.setSuccess(true);
        dto.setObj(receipt_order_service.selectReceipt_order(code));
        return dto;
    }

    @Override
    public Dto<List<Receipt_order>> allReceipt_order() {
        Dto<List<Receipt_order>> dto=new Dto<>();
        dto.setObj(receipt_order_service.allReceipt_order());
        dto.setSuccess(true);
        return dto;
    }


    @Override
    public Dto<BigDecimal> selectallReceipt_ordermoney(String code) {
        Dto<BigDecimal> dto=new Dto<>();
        dto.setSuccess(true);
        dto.setObj(receipt_order_service.selectallReceipt_ordermoney(code));
        return dto;
    }

    @Override
    public Dto addReceipt_order(Receipt_order receipt_order) {
        Dto dto=new Dto();
        dto.setSuccess(true);
        dto.setObj(receipt_order_service.addReceipt_order(receipt_order));
        return dto;
    }

    @Override
    public Dto zuofei( Map<String ,Object> map) {
        Dto dto=new Dto();
        dto.setSuccess(true);
        dto.setObj(receipt_order_service.zuofei(map));
        return dto;
    }

    @Override
    public Dto shenhe(Map<String,Object> map) {
        Dto dto=new Dto();
        dto.setSuccess(true);
        map.put("examineTime",new Date());
        dto.setObj(receipt_order_service.shenhe(map));
        return dto;
    }

    @Override
    public Dto<PageInfo<Journal>> alljournal(Map<String, Object> map) {
        Integer pageNum=Integer.parseInt(map.get("pageNun").toString());
        int navigatePages=5;
        Integer pageSize=Integer.parseInt(map.get("pageSize").toString());
        PageHelper.startPage(pageNum,pageSize);//开始分页,设参数
        List<Journal> list =receipt_order_service.alljournal(map);//查询数据
        PageInfo<Journal> pageInfo = new PageInfo<>(list,navigatePages);//数据放入自动参数分页
        Dto dto=new Dto();
        dto.setSuccess(true);
        dto.setObj(pageInfo);
        return dto;
    }

    @Override
    public Dto<PageInfo<Fukuandan>> allPay_order(Map<String, Object> map) {
        return receipt_order_service.allPay_order(map);
    }

    @Override
    public Dto addPay_order(Pay_order pay_order) {
        return receipt_order_service.addPay_order(pay_order);
    }

    @Override
    public Dto fukuanzuofei( Map<String,Object> map) {
        return receipt_order_service.fukuanzuofei(map);
    }

    @Override
    public Dto selectpay_order(String code) {
        return receipt_order_service.selectpay_order(code);
    }

    @Override
    public Dto fukuanshenhe(Map<String, Object> map) {
        return receipt_order_service.fukuanshenhe(map);
    }

    @Override
    public Dto<PageInfo<Kehuduizhang>> selectusermoney(Map<String, Object> map) {
        return receipt_order_service.selectusermoney(map);
    }

    @Override
    public Dto<Kehuduizhang> selectusersum() {
        return receipt_order_service.selectusersum();
    }

    @Override
    public Dto<Kehuduizhang> selectoneusersum(String id) {
        return receipt_order_service.selectoneusersum(id);
    }

    @Override
    public Dto<PageInfo<BuyOrder>> selectoneuseralldan(Map<String, Object> map) {
        return receipt_order_service.selectoneuseralldan(map);
    }

    @Override
    public Dto<PageInfo<Zijinduizhang>> selectdangtianzhang(Map<String,Object> map) {
        return receipt_order_service.selectdangtianzhang(map);
    }

    @Override
    public Dto<PageInfo<Journal>> selectzijinmingxi(Map<String, Object> map) {
        return receipt_order_service.selectzijinmingxi(map);
    }

    @Override
    public Dto<List<Day>> zijinzhexiantu() {
        return receipt_order_service.zijinzhexiantu();
    }

    @Override
    public Dto<List<Receipt_order>> codeselectallreceipt(String code) {
        return receipt_order_service.codeselectallreceipt(code);
    }

    @Override
    public Dto<List<Pay_order>> codeselectallfukuandan(String code) {
        return receipt_order_service.codeselectallfukuandan(code);
    }

    @Override
    public Dto selectallokfukuandan(String code) {
        return receipt_order_service.selectallokfukuandan(code);
    }

    @Override
    public Dto upPay_order(Map<String, Object> map) {
        return receipt_order_service.upPay_order(map);
    }


}
